package com.cloudsigns.factorymanager2.engineering.presenter;

import com.cloudsigns.factorymanager2.engineering.IView.IPublicationMediaListByRegionForManagerView;
import com.cloudsigns.factorymanager2.engineering.bean.PublicationOrderDetailBean;
import com.cloudsigns.factorymanager2.engineering.model.IPublicationMediaListByRegionForManagerModel;
import com.cloudsigns.factorymanager2.engineering.model.PublicationMediaListByRegionForManagerModel;

import java.util.List;

/**
 * Created by tony on 2018/6/17.
 */

public class PublicationMediaListByRegionForManagerPresenter {
    private IPublicationMediaListByRegionForManagerView view;
    private IPublicationMediaListByRegionForManagerModel model;
    private android.os.Handler mHandler = new android.os.Handler();

    public PublicationMediaListByRegionForManagerPresenter(IPublicationMediaListByRegionForManagerView view) {
        this.view = view;
        this.model = new PublicationMediaListByRegionForManagerModel();
    }

    public void publicationMediaListByRegionForManager() {

        view.showLoading();

        model.publicationMediaListByRegionForManager(view.getRegionId(),new PublicationMediaListByRegionForManagerModel.OnPublicationMediaListByRegionForManagerListener() {
            @Override
            public void publicationMediaListByRegionForManagerSuccessed(final  List<PublicationOrderDetailBean> publicationOrderDetailBeanList) {
                //需要在UI线程执行
                mHandler.post(new Runnable() {
                    @Override
                    public void run() {
                        view.publicationMediaListByRegionForManagerSuccessed(publicationOrderDetailBeanList);
                        view.hideLoading();
                    }
                });
            }

            @Override
            public void publicationMediaListByRegionForManagerFailed(final String desc) {
                mHandler.post(new Runnable() {
                    @Override
                    public void run() {
                        view.publicationMediaListByRegionForManagerFailed(desc);
                        view.hideLoading();
                    }
                });
            }


        });
    }
}
